/*******************************************************************************
 * 版权：北京润尼尔网络科技有限公司，保留所有版权<br>
 * 版本：v1.0.0<br>
 * 文件：OrthogonalSelectionFeedbackPolicy.js<br>
 * 日期：2016年11月8日<br>
 * 作者: 王志远<br>
 * 功能：<br>
 * 
 * 修改记录：<br>
 * 日期 描述 更新功能<br>
 ******************************************************************************/

window.makeNamespace(window,"Rainier.UI.V2");

/**
 * 类型名称：Rainier.UI.V2.OrthogonalSelectionFeedbackPolicy<br>
 * 类型功能：直角选择策略<br>
 */
Rainier.UI.V2.OrthogonalSelectionFeedbackPolicy = draw2d.policy.line.OrthogonalSelectionFeedbackPolicy.extend({

    NAME : "Rainier.UI.V2.OrthogonalSelectionFeedbackPolicy",

    /**
     * @constructor 
     * Creates a new Router object
     */
    init: function(attr, setter, getter){
    	this._super(attr, setter, getter);
    },
    
    /**
     * @method
     * 
     * @template
     * @param {draw2d.Connection} connection the selected figure
     * @param {Boolean} isPrimarySelection
     */
    onSelect: function(canvas, connection, isPrimarySelection){
    	this._super(canvas, connection, isPrimarySelection);
    	connection.selectionHandles.each(function(i,e){
            e.setDraggable(connection.isResizeable());
            e.hide();
        });
    	connection.selectionHandles.clear();
    },
    
    /**
     * @method
     *
     * @param {draw2d.Figure} figure the shape below the mouse or null
     * @param {Number} x the x-coordinate of the mouse down event
     * @param {Number} y the y-coordinate of the mouse down event
     * @param {Boolean} shiftKey true if the shift key has been pressed during this event
     * @param {Boolean} ctrlKey true if the ctrl key has been pressed during the event
     */
    onMouseUp: function(canvas, x, y, shiftKey, ctrlKey){ 

        var newX = x;
        var newY = y;
        
 	   	if(newX % 9 !== 0){
 			newX = newX - newX % 9;
 		}
 		if(newY % 9 !== 0){
 			newY = newY - newY % 9;
 		}
 		this._super(canvas, newX, newY, shiftKey, ctrlKey);
    },
    
    /**
	 * 函数名称：Rainier.UI.V2.OrthogonalSelectionFeedbackPolicy.onRightMouseDown<br>
	 * 函数功能：屏蔽连线默认菜单<br>
	 * 参数输入：<br>
	 * 参数输出：<br>
	 * 函数返回：<br>
	 * 异常信息：<br>
	 */
    onRightMouseDown : function(){
    	
    },
});